Scripting


There are several URLs that you can use to control Welcome.

All these URLs start with .../pi_admin.welcome? and you can easily call them from a script or use them as shortcuts to the web interface. However, if you like to call one of them, you have to deal with your realm protection. To successfully access those URLs, you will need to know how your username/password is encoded in the http header. If you have WebSTAR, you could

  • Set "Verbose Mode" to on
  • Request a page that is realm protected
  • WebSTAR will print the full request to the log window and this includes the scrambled password too
  • Simply copy the password parameter out of the window and paste it into your script

Here are the calls:


pi_admin.welcome?host
Will show you the host list. More like a shortcut than for scripting.


pi_admin.welcome?rules
Will show you the rule list. More like a shortcut than for scripting.


pi_admin.welcome?prefs
Will show you the preferences. More like a shortcut than for scripting.


pi_admin.welcome?test
Will show you the testing page. More like a shortcut than for scripting.


pi_admin.welcome?reload
Will reload the "Welcome Data" file. This file contains the virtual host configuration (data fork) and all rules (resource fork). It also resets the color statistics.


pi_admin.welcome?reset
Will reset the hit statistics (text at the Welcome homepage)


pi_admin_stats.welcome?n or stats.welcome?n
Will show the color stats as a JPEG picture. It depends on the prefs settings if you can use the first (private) or the second (public) call. The parameter n is within the range of 1..6 and will request different jpeg qualities.


Automatic 1x1 Pixel Color Gif
As a result of the built-in realtime color preview, you can use Welcome as a 1x1 pixel gif generator. Simply call Welcome inside of a <IMG SRC="/gif.welcome..."WIDTH=x HEIGHT=y> tag like this:

  • gif.welcome?t for a transparent 1x1 pixel gif
  • gif.welcome?hrrggbb for a 1x1 pixel color gif and the color is set as hex numbers rrggbb. Example: gif.welcome?hFF0000 will give you a red gif
  • gif.welcome?pr,g,b for a 1x1 pixel color gif and the color is set as percentage numbers r, g and b (between 0 and 100). Example: gif.welcome?p0,100,0 will give you a green gif
  • gif.welcome?dr,g,b for a 1x1 pixel color gif and the color is set as decimal numbers r, g and b (between 0 and 255). Example: gif.welcome?d0,0,255 will give you a blue gif


pi_admin.welcome?switch=rule_numbers
Will enable/disable rules. "rule_numbers" should be a list of numbers which you would like to enable or disable. Simply add a "+"(enable) or a "-" (disable) in front of every number or use a "a" for all rules. If a number is out of range, it will be ignored.
Examples:
switch=+2+4-3 will enable rule 2 and rule 4 and disable rule 3
switch=-a+3 will disable all rules and then enable rule 3


pi_admin.welcome?getrule=rule_number
Will show you all parameters for a rule. If rule_number is out of range, the result is "out of bounds". The result is a text that will be (parameter names instead of values in brackets):

[name]<BR>
[disabled]<BR> (will be "true" or "false")
[path]<BR>
[host]<BR>
[referer]<BR>
[language]<BR>
[browser]<BR>
[condition]<BR>
[result]<BR>
[redirect]<BR> (will be "true" or "false")
[jumpto]<BR>


pi_admin.welcome?setrule=rule_number&param=name&value=x
Will set the parameter "name" of rule "rule_number"to value "x". If rule_number is out of range, the result is "out of bounds". Use the names in the getrule list above for valid "name"tokens.

 

Format of Welcome Data
(<cr> is ASCII 13 and <tab> is ASCII 9)

[version] <cr>
[:path to click through page] <tab> [:path to host list page] <cr>
[host] <tab> [/subfolder] <tab> [index file] <tab> [Slash? N/Y/S] <tab> [:error file] <tab>[description] <tab> [Stats? Y/N] <tab> [Red %] <tab> [Green %] <tab> [Blue %] <cr>
... more host lines ...
[last host line] <cr>

If you like, you can open the file "Welcome Data" in a text editor such as BBEdit and take a look at your current configuration. Remember to reload (see above) your changes if you have modified the file.